<?PHP
require_once("./top-config.php");
?>
<?PHP
$fgmembersite->Quick_Control_Select_Groups_Handler($_GET['group_name'], $formvar);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><?PHP $fgmembersite->GetString('Edit group','Thay đổi thông tin của nhóm')?></title>
<?PHP
require_once("./pre-config.php");
?>
</head> 
<body>
<?PHP
require_once("./main-nav.php");
?>
<div class="container">
    <div class="row">
<?PHP
    print '<div class="col-md-'.$_SESSION['main-div-left'].'">';
	print '</div>';
    print '<div class="col-md-'.$_SESSION['main-div-center'].'">';
?>
			<form id='create-new-group' action='<?php echo $fgmembersite->GetSelfScript(); ?>' method='post' accept-charset='UTF-8'>
				<div id="notice-board">
					<?PHP $fgmembersite->GetErrorMessage()?>				
				</div>
				<div class="form-group">
					<h4 class="text-primary"><?PHP $fgmembersite->GetString('Edit group:','Thay đổi thông tin của nhóm:')?></h4>
					<label for="inputgroup_name" ><?PHP $fgmembersite->GetString('Group name*','Tên nhóm*')?></label>
					<input type="text" class="form-control" name="group_name" id="group_name" value='<?php echo $fgmembersite->SafeDisplay('group_name'); ?>' maxlength="32"/>
					<label for="inputOffice_name" ><?PHP $fgmembersite->GetString('Office name*','Tên cơ quan*')?></label>
					<input type="text" class="form-control" name="office_name" id="office_name" value='<?php echo $fgmembersite->SafeDisplay('office_name'); ?>' maxlength="128"/>
					<label for="inputPurpose"><?PHP $fgmembersite->GetString('Purpose*','Mục đích*')?></label>
					<input type="text" class="form-control" name="purpose" id="purpose" value='<?php echo $fgmembersite->SafeDisplay('purpose'); ?>' maxlength="128"/>
					<label for="inputPlace"><?PHP $fgmembersite->GetString('Place*','Địa điểm*')?></label>
					<input type="text" class="form-control" name="place" id="place" value='<?php echo $fgmembersite->SafeDisplay('place'); ?>' maxlength="128"/>
					<label for="inputEmail">Email*</label>
					<input type="text" class="form-control" name="email" id="email" value='<?php echo $fgmembersite->SafeDisplay('email'); ?>' maxlength="32"/>
					<label for="inputPhone"><?PHP $fgmembersite->GetString('Phone*','Số điện thoại*')?><small><?PHP $fgmembersite->GetString('(All digits)','(Tất cả ký tự số)')?></small>*</label>
					<input type="text" class="form-control" name="phone" id="phone" value='<?php echo $fgmembersite->SafeDisplay('phone'); ?>' maxlength="32"/>
					<label for="inputstart_time"><?PHP $fgmembersite->GetString('Start time*','Thời gian bắt đầu*')?> <small>(YYYY-MM-DD HH:MM:SS)</small>*</label>
					<input type="text" class="form-control" name="start_time" id="start_time" value='<?php echo $fgmembersite->SafeDisplay('start_time'); ?>'/>
					<label for="inputend_time"><?PHP $fgmembersite->GetString('Close time*','Thời gian kết thúc*')?> <small>(YYYY-MM-DD HH:MM:SS)</small>*</label>
					<input type="text" class="form-control" name="end_time" id="end_time" value='<?php echo $fgmembersite->SafeDisplay('end_time'); ?>'/>
					<label for="inputCaptcha">Captcha*</label>
					</br>
					<img src="image.php" id="img-captcha"/>
					<input type="button" value='<?PHP $fgmembersite->GetString('Reload','Tải lại')?>' onclick="$('#img-captcha').attr('src', 'image.php?rand=' + Math.random())" /> <br/>
					<input type="text" id="captcha" value="" />
				</div>
				<button id="submit" type="submit" name='Submit' class="btn btn-success center-block"><?PHP $fgmembersite->GetString('Update','Thay đổi')?></button>
			</form>
		</div>
<?PHP
    print '<div class="col-md-'.$_SESSION['main-div-right'].'">';
	print '</div>';
?>	
    </div>
</div>
<?PHP
require_once("./footer.php");
?>
<script language="javascript">
$(document).ready(function()
{
	$('#submit').click(function()
	{
		// Lấy dự liệu
		var data = 
		{
			command : 'edit-group',
			group_name : $('#group_name').val(),
			office_name : $('#office_name').val(),
			purpose : $('#purpose').val(),
			place : $('#place').val(),
			email : $('#email').val(),
			phone : $('#phone').val(),
			start_time : $('#start_time').val(),
			end_time : $('#end_time').val(),
			captcha : $('#captcha').val()
		};
		
		$.ajax(
		{
			type : 'POST',
			dataType : 'json',
			url : 'ajax_validate.php',
			data : data,
			success : function (result)
			{
				if (result['error'] == 'success')
				{
					document.getElementById("notice-board").className = 'alert alert-success fade in';
					document.getElementById("notice-board").innerHTML = '<strong>Success! Thank you</strong>';
					window.location.href= document.referrer;
				}
				else
				{
					document.getElementById("notice-board").className = 'alert alert-danger fade in';
					document.getElementById("notice-board").innerHTML = '<strong>Error! ' + result['error'] + '</strong>';
				}
			},
			error : function ()
			{
				document.getElementById("notice-board").className = 'alert alert-danger fade in';
				document.getElementById("notice-board").innerHTML = '<strong>Error! Error in processing.</strong>';
			}
		});
		return false;
	});
});
</script>
</body>

</html>                                		